/**
 * 
 */
package com.gr.staffpm.pages.behaviour;

import org.apache.wicket.behavior.AbstractBehavior;
import org.apache.wicket.markup.html.IHeaderResponse;

import com.gr.staffpm.pages.schedule.ExtCalendarToolbar;

/**
 * @author Graham Rhodes 19 Mar 2011 12:33:10
 */
public class ExtCalendarToolbarBehaviour extends AbstractBehavior {

    private static final long serialVersionUID = 1L;
    private final ExtCalendarToolbar tbar;

    public ExtCalendarToolbarBehaviour(ExtCalendarToolbar tbar) {
        this.tbar = tbar;
    }

    @Override
    public void renderHead(IHeaderResponse iHeaderResponse) {
        super.renderHead(iHeaderResponse);

        iHeaderResponse.renderOnLoadJavascript("console.log('add pressed');\n"
                + "jQuery('.x-btn-pressed').removeClass('x-btn-pressed');\n"
                + "jQuery(\".x-btn-text:contains('"
                + tbar.getCurrentView().toString()
                + "')\").closest('.x-btn').addClass('x-btn-pressed');\n"
                + "jQuery('.x-btn').hover(function(){\n"
                + "console.log('hover');\n"
                + "     $(this).addClass('x-btn-over');\n"
                + "},function(){"
                + "     $(this).removeClass('x-btn-over');\n"
                + "});\n"
                + "jQuery('.x-btn-selectable').click(function(){\n"
                + "console.log('remove old pressed and set new pressed');\n"
                + "       jQuery('.x-btn-selectable').removeClass('x-btn-pressed');\n"
                + "       jQuery(\".x-btn-text:contains('"
                + tbar.getCurrentView().toString()
                + "')\").closest('.x-btn').addClass('x-btn-pressed');\n"
                + "});");
    }

}
